<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 7.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.ico">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha256-wiz7ZSCn/btzhjKDQBms9Hx4sSeUYsDrTLg7roPstac=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.css" integrity="sha256-6cQIC71/iBIYXFK+0RHAvwmjwWzkWd+r7v/BX3/vZDc=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/themes/green/pace-theme-minimal.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/pace.min.js" integrity="sha256-gqd7YTjg/BtfqWSwsJOvndl0Bxc8gFImLEkXQT8+qj0=" crossorigin="anonymous"></script>

<script class="next-config" data-name="main" type="application/json">{"hostname":"sumumm.github.io","root":"/","images":"/images","scheme":"Gemini","darkmode":false,"version":"8.19.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":true,"style":"mac"},"fold":{"enable":true,"height":300},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":true,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="本文主要是蓝牙Mesh进阶——蓝牙Mesh配网流程的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:type" content="article">
<meta property="og:title" content="LV03-03-蓝牙Mesh进阶-02-蓝牙Mesh配网流程">
<meta property="og:url" content="https://sumumm.github.io/post/f96bb716.html">
<meta property="og:site_name" content="苏木">
<meta property="og:description" content="本文主要是蓝牙Mesh进阶——蓝牙Mesh配网流程的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20200721085517737.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20200721085612542.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20200721085714331.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20200721085931509.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20231227000103807.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20231227073138506.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20200721101709356.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20231227214146512.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20200721113354118.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20200721113741293.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20231227214630061.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20200721115141133.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20231227214931495.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20231227215521153.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20231227215858088.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20231227220033926.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20200720113708649.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20231227221235085.png">
<meta property="article:published_time" content="2024-01-07T03:45:31.000Z">
<meta property="article:modified_time" content="2025-06-13T16:25:57.027Z">
<meta property="article:author" content="苏木">
<meta property="article:tag" content="LV21-天猫精灵IOT">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20200721085517737.png">


<link rel="canonical" href="https://sumumm.github.io/post/f96bb716.html">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"https://sumumm.github.io/post/f96bb716.html","path":"post/f96bb716.html","title":"LV03-03-蓝牙Mesh进阶-02-蓝牙Mesh配网流程"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>LV03-03-蓝牙Mesh进阶-02-蓝牙Mesh配网流程 | 苏木</title>
  








    <script src="/js/browser_tools_disable.js"></script>

  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<!-- hexo injector head_end start --><link rel="stylesheet" href="https://unpkg.com/hexo-next-tags-plus@latest/lib/tag_plus.css" media="defer" onload="this.media='all'"><!-- hexo injector head_end end --></head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">苏木</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">我的学习之路</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>苏木的家</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类页<span class="badge">42</span></a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档页<span class="badge">673</span></a></li><li class="menu-item menu-item-flink"><a href="/flink/" rel="section"><i class="fa fa-link fa-fw"></i>友人帐</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于我</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%80%E3%80%81%E5%85%A5%E7%BD%91%E7%9A%84%E7%9B%AE%E7%9A%84"><span class="nav-text">一、入网的目的</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%8C%E3%80%81%E5%85%A5%E7%BD%91%E8%BF%87%E7%A8%8B"><span class="nav-text">二、入网过程</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E9%82%80%E8%AF%B7"><span class="nav-text">1. 邀请</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E5%8A%A0%E5%AF%86%E6%88%90%E5%AE%89%E5%85%A8%E9%80%9A%E9%81%93"><span class="nav-text">2. 加密成安全通道</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E8%AE%A4%E8%AF%81"><span class="nav-text">3. 认证</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-%E5%88%86%E5%8F%91%E5%AF%86%E9%92%A5"><span class="nav-text">4. 分发密钥</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%89%E3%80%81%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E8%BF%87%E7%A8%8B"><span class="nav-text">三、蓝牙Mesh配网过程</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E5%87%A0%E4%B8%AA%E5%90%8D%E8%AF%8D"><span class="nav-text">1. 几个名词</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-1-%E9%85%8D%E7%BD%91%E8%A7%92%E8%89%B2"><span class="nav-text">1.1 配网角色</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-2-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E5%8D%8F%E8%AE%AE"><span class="nav-text">1.2 蓝牙Mesh配网协议</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-2-1-%E5%8D%8F%E8%AE%AE%E6%A1%86%E5%9B%BE"><span class="nav-text">1.2.1 协议框图</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#1-2-2-%E9%85%8D%E7%BD%91%E6%95%B0%E6%8D%AE%E5%8C%85PDU%E6%A0%BC%E5%BC%8F"><span class="nav-text">1.2.2 配网数据包PDU格式</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E9%85%8D%E7%BD%91%E6%AD%A5%E9%AA%A4%EF%BC%88ADV%E6%A8%A1%E5%BC%8F%EF%BC%89"><span class="nav-text">2. 配网步骤（ADV模式）</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#2-1-%E4%BF%A1%E6%A0%87%E9%98%B6%E6%AE%B5%EF%BC%88Beacons%EF%BC%89"><span class="nav-text">2.1 信标阶段（Beacons）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-2-%E9%82%80%E8%AF%B7%E9%98%B6%E6%AE%B5"><span class="nav-text">2.2 邀请阶段</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-3-%E4%BA%A4%E6%8D%A2%E5%85%AC%E9%92%A5%E9%98%B6%E6%AE%B5"><span class="nav-text">2.3 交换公钥阶段</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-4-%E8%BA%AB%E4%BB%BD%E8%AE%A4%E8%AF%81"><span class="nav-text">2.4 身份认证</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-5-%E5%88%86%E5%8F%91%E9%85%8D%E7%BD%91%E6%95%B0%E6%8D%AE"><span class="nav-text">2.5 分发配网数据</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%9B%9B%E3%80%81%E6%80%BB%E7%BB%93%E4%B8%80%E4%B8%8B%EF%BC%9F"><span class="nav-text">四、总结一下？</span></a></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="苏木"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">苏木</p>
  <div class="site-description" itemprop="description">莫道桑榆晚，为霞尚满天</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">673</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">42</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">43</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://github.com/sumumm" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;sumumm" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://sumumm.github.io/post/f96bb716.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="苏木">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏木">
      <meta itemprop="description" content="莫道桑榆晚，为霞尚满天">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="LV03-03-蓝牙Mesh进阶-02-蓝牙Mesh配网流程 | 苏木">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          LV03-03-蓝牙Mesh进阶-02-蓝牙Mesh配网流程
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2024-01-07 11:45:31" itemprop="dateCreated datePublished" datetime="2024-01-07T11:45:31+08:00">2024-01-07</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/" itemprop="url" rel="index"><span itemprop="name">嵌入式开发</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/" itemprop="url" rel="index"><span itemprop="name">01HQ课程体系</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/" itemprop="url" rel="index"><span itemprop="name">LV21-天猫精灵IOT</span></a>
        </span>
    </span>

  
    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>7.1k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>26 分钟</span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><p>本文主要是蓝牙Mesh进阶——蓝牙Mesh配网流程的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。</p>
<span id="more"></span>

<!-- Photo: https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/ -->

<details class="folding-tag" blue><summary> 点击查看使用工具及版本 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center" width=150px>Windows版本</td>        <td align="left">windows11</td>    </tr>    <tr>        <td align="center">Ubuntu版本</td>        <td align="left">Ubuntu22.04的64位版本</td>      </tr>    <tr>        <td align="center">VMware® Workstation 16 Pro</td>        <td align="left">16.2.3 build-19376536</td>      </tr>    <tr>        <td align="center">终端软件</td>        <td align="left">MobaXterm(Professional Edition v23.0 Build 5042 (license))</td>      </tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看本文参考资料 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center">分类</td>        <td align="center">网址</td>        <td align="center">说明</td>    </tr>    <tr>        <td align="center" rowspan="6">官方网站</td>        <td align="left"><a href="https://cn.aliyun.com/" target="_blank">阿里云</a></td>        <td align="left">阿里云官网主页</td>    </tr>    <tr>        <td align="left"><a href="https://www.aliyun.com/product/iot/livinglink?spm=5176.28508143.J_4VYgf18xNlTAyFFbOuOQe.317.5421154acZniIL&scm=20140722.X_data-1da961ea118f5bb0e4b2._.V_1" target="_blank">阿里生活物联平台</a></td>        <td align="left">生活物联网平台(飞燕平台)主页</td>    </tr>    <tr>        <td align="left"><a href="https://iap.aligenie.com/?spm=0.7629140.0.0.2c611780Ty6tzg" target="_blank">AliGenie</a></td>        <td align="left">天猫精灵开放平台AliGenie主页</td>    </tr>    <tr>        <td align="left"><a href="https://www.aliyun.com/product/iot/iot_instc_public_cn?spm=5176.28508143.J_4VYgf18xNlTAyFFbOuOQe.81.5421154au3ocqp&scm=20140722.X_data-9349178ba84cf028806a._.V_1" target="_blank">阿里物联网平台</a></td>        <td align="left">阿里物联网平台主页</td>    </tr>    <tr>        <td align="left"><a href="https://www.bluetooth.com/zh-cn/" target="_blank">Bluetooth 技术网站</a></td>        <td align="left">蓝牙协议规范什么的可以来这里找</td>    </tr>    <tr>        <td align="left"><a href="https://www.telink-semi.com/" target="_blank">Telink</a></td>        <td align="left">Telink | Chips for a Smarter IoT (telink-semi.com)<br><a href="https://www.telink-semi.cn/" target="_blank">Telink中文官网</a></td>    </tr>    <tr>        <td align="center" rowspan="5">开发手册</td>        <td align="left"><a href="https://help.aliyun.com/zh/alios-things/" target="_blank">AliOS Things开发指南</a></td>        <td align="left">AliOS Things开发指南，这里是最新版本，可以直接从官网找到</td>    </tr>     <tr>        <td align="left"><a href="https://haas.iot.aliyun.com/aliosthings/index.html" target="_blank">AliOS Things开发指南</a></td>        <td align="left">AliOS Things应用开发指南，这里应该是3.3版本的完整开发文档</td>    </tr>    <tr>        <td align="left"><a href="https://gaic.alicdn.com/aic/h5_daily/test/aliosthings/3.0.13/index.html" target="_blank">AliOS Things开发指南(3.0)</a></td>        <td align="left">AliOS Things应用开发指南，这里应该是3.0版本的完整开发文档</td>    </tr>    <tr>        <td align="left"><a href="https://help.aliyun.com/product/123207.html?spm=a2c4g.11186623.6.540.114e60d84sF58G" target="_blank">生活物联网平台开发文档</a></td>        <td align="left">生活物联网平台（飞燕平台）开发文档<br><a href="https://help.aliyun.com/document_detail/180778.html?spm=a2c4g.123207.0.0.49556adcO5apvd" target="_blank">《设备端开发指南》</a></td>    </tr>    <tr>        <td align="left"><a href="https://doc-bot.tmall.com/docs/doc.htm?spm=0.7629140.0.0.7bf81780UN7WkQ&treeId=578&articleId=118057&docType=1" target="_blank">Wi-Fi IoT品类定义与功能开发</a></td>        <td align="left">天猫精灵IoT开放平台——Wi-Fi IoT品类定义与功能开发</td>    </tr>    <tr>        <td align="center" rowspan="3">硬件平台</td>        <td align="left"><a href="https://developer.aliyun.com/article/761644?spm=a2c6h.12873581.0.dArticle761644.1c1b589dRHgvcR&groupCode=genieaiot" target="_blank">mk3080 WiFi开发板</a></td>        <td align="left">WiFi开发板使用指南-阿里云开发者社区</td>    </tr>    <tr>        <td align="left"><a href="http://www.taichi-maker.com/homepage/esp8266-nodemcu-iot/esp8266-nodemcu-tutorial-index/" target="_blank">esp8266开发板</a></td>        <td align="left">一个教程：ESP8266-NodeMCU开发板详解-太极创客 (taichi-maker.com)</td>    </tr>    <tr>        <td align="left"><a href="https://wiki.telink-semi.cn/doc/ds/DS_TLSR8258-E_Datasheet%20for%20Telink%20BLE+IEEE802.15.4%20Multi-Standard%20Wireless%20SoC%20TLSR8258.pdf" target="_blank">TLSR8258 Datasheet</a></td>        <td align="left">Datasheet for Telink BLE + IEEE802.15.4 MultiStandard Wireless SoC TLSR8258</td>    </tr>    <tr>        <td align="center" rowspan="2">参考资料</td>        <td align="left"><a href="https://developer.aliyun.com/article/720516#" target="_blank">AliOS Things 3.0 应用开发指南</a></td>        <td align="left">这个只是一篇参考文章，里面是一些环境搭建相关的，可以参考</td>    </tr>    <tr>        <td align="left"><a href="https://info.support.huawei.com/info-finder/encyclopedia/zh/index.html" target="_blank">IP知识百科 - 华为 (huawei.com)</a></td>        <td align="left">IP的一些相关知识点</td>    </tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看相关文件下载 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center" width=150px>分类</td>        <td align="center">网址</td>        <td align="center">说明</td>    </tr>    <tr>        <td align="left" rowspan="6">蓝牙规范相关文档</td>        <td align="left"><a href="https://www.bluetooth.com/zh-cn/specifications/specs/core-specification-5-2/" target="_blank">Core Specification 5.2</a></td>        <td align="left">核心规格 5.2，该规范定义了创建可互操作的Bluetooth 设备所需的技术。                        <br><a href="./蓝牙参考资料/Core_v5.2.pdf" target="_blank">《Core_v5.2.pdf》</a></td>      </tr>    <tr>        <td align="left"><a href="https://www.bluetooth.com/zh-cn/specifications/specs/mesh-model-1-1/" target="_blank">Mesh Model(v1.1)</a></td>        <td align="left">本Bluetooth 规范定义了模型（以及它们所需的状态和消息），这些模型用于在mesh 网络中的节点上执行基本功能，超出了Bluetooth Mesh 配置文件 规范中定义的基础模型。                        <br>本规范包括定义跨设备类型标准功能的通用模型，以及支持关键mesh 场景的模型，如照明控制、传感器、时间和场景。                        <br><a href="./蓝牙参考资料/MshMDL_v1.1.pdf" target="_blank">《MshMDL_v1.1.pdf》</a></td>      </tr>    <tr>        <td align="left"><a href="https://www.bluetooth.com/zh-cn/specifications/specs/mesh-profile-1-0-1/" target="_blank">Mesh Profile(v1.0.1)</a></td>        <td align="left">该Bluetooth 规范定义了基本要求，以实现可互操作的mesh 网络解决方案，用于Bluetooth 低能量无线技术。                        <br><a href="./蓝牙参考资料/MshPRFv1.0.1.pdf" target="_blank">《MshPRFv1.0.1.pdf》</a></td>      </tr>    <tr>        <td align="left"><a href="https://www.bluetooth.com/zh-cn/specifications/device-properties/" target="_blank">Mesh Device Properties</a></td>        <td align="left">本规范包含Bluetooth Mesh 配置文件 和Bluetooth Mesh 模型规范所要求的设备属性的定义。                        <br>但是跟之前的有些区别，我主要看的之前的版本：<a href="./蓝牙参考资料/MeshDeviceProperties_v1.2.pdf" target="_blank">《MMeshDeviceProperties_v1.2.pdf》</a></td>      </tr>    <tr>        <td align="left"><a href="https://www.bluetooth.com/specifications/gss/" target="_blank">GATT Specification Supplement</a></td>        <td align="left">GATT Specification Supplement | Bluetooth® Technology Website。                        <br>好像可以在线看：<a href="https://btprodspecificationrefs.blob.core.windows.net/gatt-specification-supplement/GATT_Specification_Supplement.pdf" target="_blank">《GATT Specification Supplement》</a></td>      </tr>     <tr>        <td align="left"><a href="https://www.bluetooth.com/specifications/assigned-numbers/" target="_blank">Assigned Numbers</a></td>        <td align="left">GATT的一些类型定义可以在这里找。</td>      </tr>    <tr>        <td align="left" rowspan="2">AliOS Things</td>        <td align="left"><a href="https://gitee.com/alios-things-admin/AliOS-Things" target="_blank">alios-things/AliOS-Things</a></td>        <td align="left">Gitee上的AliOSThings SDK源码仓库</td>      </tr>    <tr>        <td align="left"><a href="https://github.com/alibaba/AliOS-Things" target="_blank">alibaba/AliOS-Things</a></td>        <td align="left">GitHub上的AliOSThings SDK源码仓库</td>      </tr>    <tr>        <td align="left" rowspan="2">天猫精灵蓝牙Mesh协议栈</td>        <td align="left"><a href="https://github.com/alibaba-archive/genie-bt-mesh-stack" target="_blank">alibaba-archive/genie-bt-mesh-stack</a></td>        <td align="left">GitHub上的天猫精灵蓝牙Mesh协议栈源码仓库。<br>之前是在<a href="https://github.com/alibaba/genie-bt-mesh-stack"target="_blank">alibaba/genie-bt-mesh-stack</a>这个仓库。<br>写笔记的时候最新提交为<a href="https://github.com/alibaba-archive/genie-bt-mesh-stack/tree/faf523618a6a2560090fc423222b9db80984bb7a" target="_blank">faf523618a6a2560090fc423222b9db80984bb7a</a></td>      </tr>    <tr>        <td align="left"><a href="https://help.aliyun.com/document_detail/171552.html?spm=a2c4g.173310.0.0.55d6e992e8xJip" target="_blank">蓝牙Mesh设备开发指南</a></td>        <td align="left">阿里云生活服务平台开发手册——蓝牙设备开发一节中的内容</td>      </tr></table>
              </div>
            </details>


<p>我们在使用Wi-Fi会配网，使用蓝牙会配网，以及其他的无线设备都会存在一个匹配的过程，本章内容着重阐述为什么要配网以及配网的过程中解决了哪些问题，通过蓝牙Mesh入网过程，同时可以理解几乎所有无线网络的配网流程以及它背后的含义。</p>
<h1 id="一、入网的目的"><a href="#一、入网的目的" class="headerlink" title="一、入网的目的"></a><font size=3>一、入网的目的</font></h1><p>Provisioning is a process of adding an unprovisioned device to a mesh network，managed by a Provisioner. A provisioner Provides the unprovisioned device with provisioning data that allows it to become a mesh node. The provisioning data includes a network key，the current IV index，and the unicast address for each element.</p>
<p>通过官方定义（<a href="./蓝牙参考资料/MshPRFv1.0.1.pdf" target="_blank">《MshPRFv1.0.1.pdf》</a>的第五章），我们可以看出，入网的过程就是把一个未配网的设备加入到Mesh网络中的过程，配网器会给未配网的设备提供一些数据让它变成Mesh中的一个节点，其中包括network key、当前的IV index还有每个元素的单播地址（对此三个参数请参考Mesh协议章节中）。</p>
<h1 id="二、入网过程"><a href="#二、入网过程" class="headerlink" title="二、入网过程"></a><font size=3>二、入网过程</font></h1><h2 id="1-邀请"><a href="#1-邀请" class="headerlink" title="1. 邀请"></a><font size=3>1. 邀请</font></h2><p>邀请可以对应我们在手机配对蓝牙耳机或者蓝牙鼠标的模式，我们通过扫描发现了可入网的设备，点击配对就是对蓝牙设备进行了入网的邀请，对于所有配网设备来说无疑必须要有此操作，不然我们的设备到底要加入哪一个网络就不得而知了，打个比方，我们在公司打算邀请好朋友去吃饭，如果我们不告诉我们的好朋友，他怎么知道晚上要和我们去吃饭呢？这是一个道理，我们的设备进行通信首先要邀请它进入到我们的对话空间，对方同意之后在进行一步的操作。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20200721085517737.png" alt="image-20200721085517737" />

<h2 id="2-加密成安全通道"><a href="#2-加密成安全通道" class="headerlink" title="2. 加密成安全通道"></a><font size=3>2. 加密成安全通道</font></h2><p>一般的无线通信技术都会使用ECDH椭圆曲线非对称加密来创建一个加密通道进行通信，此处如何理解呢？同样打个比方，在战争时器为什么会有摩斯密码的出现呢？其根本是为了解决敌方收到我的消息，但是不能够明白我想要表达的具体含义。对于无线通信当然最直接的就是，不让黑客知道我们无线配网时的关键信息，如果被黑客知道后果不堪设想，这部分我们会在安全中详细学习。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20200721085612542.png" alt="image-20200721085612542" style="zoom:60%;" />

<h2 id="3-认证"><a href="#3-认证" class="headerlink" title="3. 认证"></a><font size=3>3. 认证</font></h2><p>认证可能直接从技术上理解会比较抽象，举个例子，当我们收到熟悉人打来的电话，声音也是本人的声音问我们借钱缴纳住院费，但是我们才刚刚分开没多久认为这是不可能的，但是对方的声音和电话号码全都吻合这时，我们应该怎么办呢？很直接的一个办法，我们约一下面谈此事，对于无线通信来说身份伪装并不是一个技术难点，所以在保证无线通信安全性上面必须要想到这一点，让对方裸漏在我们面前交换信息，这样才能真正的保证通信安全。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20200721085714331.png" alt="image-20200721085714331" style="zoom:62%;" />

<h2 id="4-分发密钥"><a href="#4-分发密钥" class="headerlink" title="4. 分发密钥"></a><font size=3>4. 分发密钥</font></h2><p>分发密钥阶段为入网的最后一个阶段，可以从上文看出，我们已经建立的最安全的通信方式，此时配网器需要给设备分发一些数据，就如同我们入职一家公司，会给我们发部分规范文件、工牌、社保卡等等，对应蓝牙Mesh中就是分发了Network key、当前的IV index还有每个元素的单播地址。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20200721085931509.png" alt="image-20200721085931509" style="zoom:50%;" />

<h1 id="三、蓝牙Mesh配网过程"><a href="#三、蓝牙Mesh配网过程" class="headerlink" title="三、蓝牙Mesh配网过程"></a><font size=3>三、蓝牙Mesh配网过程</font></h1><p>蓝牙Mesh入网流程相比上面所说的四个步骤增加了一个交换公钥的阶段，出于安全考虑不同的无线通信设备都会对自己的具体实现做出一些修改，宏观上依然是上面讲述的四步。蓝牙Mesh入网五个阶段，分别是信标阶段、邀请阶段、交换公钥交换、身份验证阶段和分发密钥数据阶段。</p>
<h2 id="1-几个名词"><a href="#1-几个名词" class="headerlink" title="1. 几个名词"></a><font size=3>1. 几个名词</font></h2><p>在每一步的之前，需要先了解几个专属名词：</p>
<h3 id="1-1-配网角色"><a href="#1-1-配网角色" class="headerlink" title="1.1 配网角色"></a><font size=3>1.1 配网角色</font></h3><p>（1）未配网设备（Unprovisioned Device）：还没有加入到任何Mesh网络中的设备。</p>
<p>（2）配网器（Provisioneder）：用来给未配网设备配网配网的，比如：天猫精灵</p>
<p>（3）Mesh节点（Mesh Node）：已经加入到蓝牙Mesh网络的每一个节点。</p>
<p>实际上我们的配网过程，就是将未配网设备变成一个Mesh节点，所以每个设备都有可能是以上三种角色的任意角色，对于配网器来说，在已经入网的节点都有可能变成配网器的身份。</p>
<h3 id="1-2-蓝牙Mesh配网协议"><a href="#1-2-蓝牙Mesh配网协议" class="headerlink" title="1.2 蓝牙Mesh配网协议"></a><font size=3>1.2 蓝牙Mesh配网协议</font></h3><h4 id="1-2-1-协议框图"><a href="#1-2-1-协议框图" class="headerlink" title="1.2.1 协议框图"></a><font size=3>1.2.1 协议框图</font></h4><p>配网协议与此前讲述的蓝牙Mesh通信协议有共同之处，很显然对于空中数据包的接收必然是一样的，只不过在识别为是Beacons数据包的时候走了不同的分支处理，就和我们作分类是一个道理，在一条传送带上放着iPhone和iPad，通过什么方式将两个产品分开呢？最直观的方式通过大小的区分，在蓝牙空中数据包中，我们需要通过类型（Type）来区分不同的数据种类进行不同的处理。</p>
<p>我们可以看一下<a href="./蓝牙参考资料/MshPRFv1.0.1.pdf" target="_blank">《MshPRFv1.0.1.pdf》</a>的5 Provisioning一节，这一章最开始的时候有配网协议图：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20231227000103807.png" alt="image-20231227000103807" style="zoom:50%;" />

<p>上图可见，对于配网协议的分层只有三层，分别为Provisioning Bearer Layer层、Provisioning Transport Layer层和Provisioning Protocol。与此前Mesh通信协议对比，Bearer层上接收到的数据是相同的，只是通过判断了类型进行了分支语句的处理。</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//广播包的流程框架</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> AD_TYPE_PB_ADV  0x29</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> AD_TYPE_MESSAGE 0x2A</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> AD_TYPE_BEACON  0x2B</span></span><br><span class="line"><span class="type">int</span> <span class="title function_">main</span><span class="params">()</span></span><br><span class="line">&#123;</span><br><span class="line">	<span class="type">int</span> user_data = AD_TYPE_PB_ADV;</span><br><span class="line">    <span class="keyword">switch</span>(user_data)</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="keyword">case</span> AD_TYPE_PB_ADV:</span><br><span class="line">            <span class="comment">//入网协议处理</span></span><br><span class="line">            </span><br><span class="line">            <span class="keyword">break</span>;</span><br><span class="line">        <span class="keyword">case</span> AD_TYPE_MESSAGE:</span><br><span class="line">            <span class="comment">//消息通信协议处理</span></span><br><span class="line">            </span><br><span class="line">            <span class="keyword">break</span>;</span><br><span class="line">        <span class="keyword">case</span> AD_TYPE_BEACON:</span><br><span class="line">            <span class="comment">//准备邀请处理</span></span><br><span class="line">            </span><br><span class="line">            <span class="keyword">break</span>;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="1-2-2-配网数据包PDU格式"><a href="#1-2-2-配网数据包PDU格式" class="headerlink" title="1.2.2 配网数据包PDU格式"></a><font size=3>1.2.2 配网数据包PDU格式</font></h4><p>我们可以看一下<a href="./蓝牙参考资料/MshPRFv1.0.1.pdf" target="_blank">《MshPRFv1.0.1.pdf》</a>的5.4.1 Provisioning PDUs一节：</p>
<p><img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20231227073138506.png" alt="image-20231227073138506"></p>
<p>为什么又有这么多类型？是因为在入网的时候有很多不同的阶段，不同的阶段都需要加以区分，就会产生这么多的类型。</p>
<h2 id="2-配网步骤（ADV模式）"><a href="#2-配网步骤（ADV模式）" class="headerlink" title="2. 配网步骤（ADV模式）"></a><font size=3>2. 配网步骤（ADV模式）</font></h2><h3 id="2-1-信标阶段（Beacons）"><a href="#2-1-信标阶段（Beacons）" class="headerlink" title="2.1 信标阶段（Beacons）"></a><font size=3>2.1 信标阶段（Beacons）</font></h3><p>信标（Beacons）阶段主要是未配网设备在广播自己要加入Mesh网络中，在此之前在蓝牙Mesh协议规范中我们有接触到蓝牙Mesh广播数据类型，回忆下AD Type（<a href="./蓝牙参考资料/Core_v5.2.pdf" target="_blank">《Core_v5.2.pdf》</a>Vol 3, Part C，11 ADVERTISING AND SCAN RESPONSE DATA  FORMAT的Figure 11.1）。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20200721101709356.png" alt="image-20200721101709356" style="zoom:50%;" />

<p>当未入网设备在等待配网器发送邀请的期间，会间隔的在空中发送AD Type为0x2B的信标包，AD Data里面则会带有其他信息，如天猫精灵的三元组信息，或者是其他公司的公司ID等等内容，对于配网器来说，扫描到空中有蓝牙数据包即进行识别，随后进行识别AD Type类型，如果是Mesh Beacon，且数据格式与此产品相符则发送邀请，如：天猫精灵找队友，发现为配网设备的Beacon包，并识别其中的三元组信息格式符合天猫精灵蓝牙Mesh规范则进行下一步操作。对应Beacon包格式如下：</p>
<table>
<thead>
<tr>
<th align="center">Parameters字段</th>
<th align="center">长度（字节）</th>
<th align="left">备注</th>
</tr>
</thead>
<tbody><tr>
<td align="center">Length</td>
<td align="center">1</td>
<td align="left">Beacon包长度</td>
</tr>
<tr>
<td align="center">Type</td>
<td align="center">1</td>
<td align="left">Beacon包类型，值为0x2B</td>
</tr>
<tr>
<td align="center">Beacon类型</td>
<td align="center">1</td>
<td align="left">未配网Beacon类型，值为0</td>
</tr>
<tr>
<td align="center">UUID</td>
<td align="center">16</td>
<td align="left">设备唯一ID</td>
</tr>
<tr>
<td align="center">OOB信息</td>
<td align="center">2</td>
<td align="left">OOB信息类型，如：NFC、二维码，此处对应天猫精灵三元组</td>
</tr>
<tr>
<td align="center">URL Hash</td>
<td align="center">4</td>
<td align="left">URL的Hash值，可以用来帮助识别设备</td>
</tr>
</tbody></table>
<p>信标阶段流程示意图：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20231227214146512.png" alt="image-20231227214146512" style="zoom: 33%;" />

<p>蓝牙Mesh设备上电后如处于未配网状态，需要广播Unprovisioned Device Beacon，每次广播时长不小于120ms，广播间隔500ms，广播持续时间一般为10分钟，具体产品的广播启动方式和广播持续时间以产品需求为准。如果超时后仍未被配网，设备关闭PB-ADV广播。信标阶段发现了设备，同时也要确定该设备是否可被连接，则进行上图的Link Open，类似我叫你一声你敢答应吗？或者我在问你是否准备好，嘿！老兄你在线不？数据包中包含UUID。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20200721113354118.png" alt="image-20200721113354118" />

<p>各个字段说明如下：</p>
<table>
<thead>
<tr>
<th>Parameters字段</th>
<th>长度（字节）</th>
<th>备注</th>
</tr>
</thead>
<tbody><tr>
<td>Link Open</td>
<td>1</td>
<td>Link open&#x3D;0 GPCF &#x3D; 3</td>
</tr>
<tr>
<td>UUID</td>
<td>16</td>
<td>设备UUID</td>
</tr>
</tbody></table>
<p>当配网器发送Link Open给未配网设备时，未配网设备接收到Link Open消息，判断是否为自己的UUID，如果是则返回Link ACK表示应答，代表可以进行通信，准备进入下一阶段，到此信标阶段就结束了。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20200721113741293.png" alt="image-20200721113741293" />

<h3 id="2-2-邀请阶段"><a href="#2-2-邀请阶段" class="headerlink" title="2.2 邀请阶段"></a><font size=3>2.2 邀请阶段</font></h3><p>配网器和未配网设备已经建立成功的连接，二者即可以通过PB-ADV或者PB-GATT承载上建立连接进行邀请阶段的数据交互，邀请阶段要完成配网器对未配网设备的设备能力信息，比如是否有屏幕、是否有键盘，这将影响到后面的认证阶段。邀请节点的基本流程如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20231227214630061.png" alt="image-20231227214630061" style="zoom:50%;" />

<p>在此过程中会下发如下数据给配网设备：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20200721115141133.png" alt="image-20200721115141133" style="zoom:50%;" />

<p>这个数据是给未配网设备得，其含义是定时，开发者可以设定未配网设备要在多长时间之内进行回复，Attention Timer state的值为0则代表关闭此功能，非零代表剩余时间，单位为秒。</p>
<p>接下来未配网设备拿到配网器的询问之后（询问配网能力）需要在指定时间内进行反馈，反馈内容如下（<a href="./蓝牙参考资料/MshPRFv1.0.1.pdf" target="_blank">《MshPRFv1.0.1.pdf》</a>的5.4.1.2 Provisioning Capabilities）：</p>
<table>
<thead>
<tr>
<th>Parameters字段</th>
<th>长度（字节）</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>Number of Elements</td>
<td>1</td>
<td>未配网设备中的元素个数，涉及到下发地址</td>
</tr>
<tr>
<td>Algorithm</td>
<td>2</td>
<td>支持的算法和其他功能，目前只有椭圆算法（Elliptic Curve）</td>
</tr>
<tr>
<td>Public Key Type</td>
<td>1</td>
<td>设备公钥类型，是否支持OOB</td>
</tr>
<tr>
<td>Static OOB Type</td>
<td>1</td>
<td>是否支持静态OOB，（out of band 带外数据）</td>
</tr>
<tr>
<td>Output OOB Size</td>
<td>1</td>
<td>输出式OOB最大长度</td>
</tr>
<tr>
<td>Output OOB Action</td>
<td>2</td>
<td>输出式OOB动作类型，如：LED闪烁、震动、输出数字、输出字母</td>
</tr>
<tr>
<td>Input OOB Size</td>
<td>1</td>
<td>输入式OOB最大长度</td>
</tr>
<tr>
<td>Input OOB Action</td>
<td>2</td>
<td>输入式OOB动作类型，如：按键、旋钮、输入数字、输入字母和数字</td>
</tr>
</tbody></table>
<h3 id="2-3-交换公钥阶段"><a href="#2-3-交换公钥阶段" class="headerlink" title="2.3 交换公钥阶段"></a><font size=3>2.3 交换公钥阶段</font></h3><p>配网器与未配网设备配网时需要下发地址、网络密钥，这些信息与整个蓝牙Mesh网络安全息息相关，所以蓝牙Mesh规范要求配网器与未配网设备在配网时需要约定加密的方式，确保加密有效需要双方交换公钥在对数据进行解密，如果拿到的值是一致的则认为双方加密有效，举个例子，摩斯密码表的发送与接收需要建立在两人均学习过摩斯密码表后才可以实现，即我们周围的人都能够听见我们各自发声，但只有我们两个才能够听懂，对于蓝牙Mesh来说，在同一网络中所有的Mesh节点都学习了本网络中的加密方式，对于外界获取到该数据包时则不会理解具体含义，具体数据加密过程在蓝牙Mesh协议分层的Network Layer层中详细阐述，配网过程的加密可以看作正在学习该加密方式并且对其数据解密验证。</p>
<p>交换公钥阶段基本流程如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20231227214931495.png" alt="image-20231227214931495" style="zoom:50%;" />

<p>在此阶段，配网器会像未配网设备发送Provisioning Start和Provisioning Public Key，看下具体数据内容：</p>
<ul>
<li>Provisioning Start</li>
</ul>
<table>
<thead>
<tr>
<th>Parameters字段</th>
<th>长度（字节）</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>Algorithm</td>
<td>1</td>
<td>算法选择，目前仅支持ECDH</td>
</tr>
<tr>
<td>Public Key</td>
<td>1</td>
<td>0x00代表不使用OOB公钥，0x01使用OOB公钥</td>
</tr>
<tr>
<td>Authentication Method</td>
<td>1</td>
<td>身份认证类型，如设备能力中阐述</td>
</tr>
<tr>
<td>Authentication Action</td>
<td>1</td>
<td>验证动作，选择OOB输入或者输出等</td>
</tr>
<tr>
<td>Authentication Size</td>
<td>1</td>
<td>验证长度</td>
</tr>
</tbody></table>
<p>如果我未配网设备存在OOB公钥则不需要反馈给配网器Public Key，如果未配网设备本身不存在OOB公钥，则需要生成Public Key发送给配网器，Public Key是由Privacy key生成的，每个设备都有自己的Privacy key。互相交换了密钥即相当于建立了安全通道。</p>
<h3 id="2-4-身份认证"><a href="#2-4-身份认证" class="headerlink" title="2.4 身份认证"></a><font size=3>2.4 身份认证</font></h3><p>在了解完第三步的时候已经建立了安全通道，二者在数据交互时采用了加密的形式，为什么还要有身份认证呢？如果能回答这个问题对于此步骤的内容也就非常清晰了。身份认证有四种形式：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20231227215521153.png" alt="image-20231227215521153" />

<p>身份认证的基本流程如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20231227215858088.png" alt="image-20231227215858088" style="zoom:50%;" />

<p>Provisioning Confirmation：</p>
<table>
<thead>
<tr>
<th>Parameters字段</th>
<th>长度（字节）</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>Confirmation</td>
<td>16</td>
<td>OOB信息</td>
</tr>
</tbody></table>
<p>Provisioning Random：</p>
<table>
<thead>
<tr>
<th>Parameters字段</th>
<th>长度（字节）</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>Random</td>
<td>16</td>
<td>此随机值为之前双方所交互的所有值和OOB随机数形成的加密散列值</td>
</tr>
</tbody></table>
<h3 id="2-5-分发配网数据"><a href="#2-5-分发配网数据" class="headerlink" title="2.5 分发配网数据"></a><font size=3>2.5 分发配网数据</font></h3><p>经历了前面的坎坷，终于可以变身成为蓝牙Mesh的节点了，这就好比我们费劲心思的去回答面试题，作答笔试题，谈好了薪资要正式入职的感觉一样，一起感受一下拿到入职工牌的喜悦吧！</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20231227220033926.png" alt="image-20231227220033926" style="zoom:50%;" />

<p>Provisioning Data：</p>
<table>
<thead>
<tr>
<th>Parameters字段</th>
<th>长度（字节）</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>Encrypted Provisioning Data</td>
<td>25</td>
<td>包括Network Key、网络密钥索引、IV index、主元素地址等</td>
</tr>
<tr>
<td>Provisioning Data MIC</td>
<td>8</td>
<td>PDU 完整性检查值</td>
</tr>
</tbody></table>
<p>Provisioning Complete：</p>
<table>
<thead>
<tr>
<th>Parameters字段</th>
<th>长度（字节）</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>无</td>
<td>无</td>
<td>无参PDU，代表配网成功。</td>
</tr>
</tbody></table>
<h1 id="四、总结一下？"><a href="#四、总结一下？" class="headerlink" title="四、总结一下？"></a><font size=3>四、总结一下？</font></h1><p>我们看一下<a href="./蓝牙参考资料/MshPRFv1.0.1.pdf" target="_blank">《MshPRFv1.0.1.pdf》</a>第五章的这一小节：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20200720113708649.png" alt="image-20200720113708649" style="zoom: 80%;" />

<p>从上图中可以得知，蓝牙Mesh如果过程分为五个阶段，分别是信标阶段、邀请阶段、交换公钥极端、身份验证阶段和分发密钥数据阶段。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/LV03-03-%E8%93%9D%E7%89%99Mesh%E8%BF%9B%E9%98%B6-02-%E8%93%9D%E7%89%99Mesh%E9%85%8D%E7%BD%91%E6%B5%81%E7%A8%8B/img/image-20231227221235085.png" alt="image-20231227221235085"  />










    </div>

    
    
    

    <footer class="post-footer">




    <div>
        
            <div style="text-align:center;color: #ccc;font-size:14px;">
            ----------本文结束
            <i class="fas fa-fan fa-spin" style="color: #FF1493; font-size: 1rem"></i>
            感谢您的阅读----------
            </div>
        
    </div>





  
  <div class="my_post_copyright"> 
    <p><span>文章标题:</span><a href="/post/f96bb716.html">LV03-03-蓝牙Mesh进阶-02-蓝牙Mesh配网流程</a></p>
    <p><span>文章作者:</span><a href="/" title="欢迎访问 《苏木》 的学习笔记">苏木</a></p>
    <p><span>发布时间:</span>2024年01月07日 - 11:45</p>
    <p><span>最后更新:</span>2025年06月14日 - 00:25</p>
    <p><span>原始链接:</span><a href="/post/f96bb716.html" title="LV03-03-蓝牙Mesh进阶-02-蓝牙Mesh配网流程">https://sumumm.github.io/post/f96bb716.html</a></p>
    <p><span>许可协议:</span><i class="fab fa-creative-commons"></i> <a rel="license" href= "https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>  
  </div>
  


          <div class="post-tags">
              <a href="/tags/LV21-%E5%A4%A9%E7%8C%AB%E7%B2%BE%E7%81%B5IOT/" rel="tag"><i class="fa fa-tag"></i> LV21-天猫精灵IOT</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/post/8bed8e87.html" rel="prev" title="LV03-03-蓝牙Mesh进阶-03-蓝牙Mesh模型">
                  <i class="fa fa-angle-left"></i> LV03-03-蓝牙Mesh进阶-03-蓝牙Mesh模型
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/post/e36d9daa.html" rel="next" title="LV03-03-蓝牙Mesh进阶-01-蓝牙Mesh网络分层">
                  LV03-03-蓝牙Mesh进阶-01-蓝牙Mesh网络分层 <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 2017 – 
    <span itemprop="copyrightYear">2025</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">苏木</span>
  </div>
<div class="wordcount">
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-line"></i>
    </span>
      <span>站点总字数：</span>
    <span title="站点总字数">3.7m</span>
  </span>
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span>站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">225:26</span>
  </span>
</div>




    <span id="sitetime"></span>
    <script defer language=javascript>
        function siteTime()
        {
            window.setTimeout("siteTime()", 1000);
            var seconds = 1000;
            var minutes = seconds * 60;
            var hours = minutes * 60;
            var days = hours * 24;
            var years = days * 365;
            var today = new Date();
            var todayYear = today.getFullYear();
            var todayMonth = today.getMonth()+1;
            var todayDate = today.getDate();
            var todayHour = today.getHours();
            var todayMinute = today.getMinutes();
            var todaySecond = today.getSeconds();
            /*==================================================
            Date.UTC() -- 返回date对象距世界标准时间(UTC)1970年1月1日午夜之间的毫秒数(时间戳)
            year        - 作为date对象的年份，为4位年份值
            month       - 0-11之间的整数，做为date对象的月份
            day         - 1-31之间的整数，做为date对象的天数
            hours       - 0(午夜24点)-23之间的整数，做为date对象的小时数
            minutes     - 0-59之间的整数，做为date对象的分钟数
            seconds     - 0-59之间的整数，做为date对象的秒数
            microseconds - 0-999之间的整数，做为date对象的毫秒数
            ==================================================*/
            var t1 = Date.UTC(2017, 
                              5, 
                              19, 
                              0, 
                              0, 
                              0); //北京时间
            var t2 = Date.UTC(todayYear,todayMonth,todayDate,todayHour,todayMinute,todaySecond);
            var diff = t2-t1;
            var diffYears = Math.floor(diff/years);
            var diffDays = Math.floor((diff/days)-diffYears*365);
            var diffHours = Math.floor((diff-(diffYears*365+diffDays)*days)/hours);
            var diffMinutes = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours)/minutes);
            var diffSeconds = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours-diffMinutes*minutes)/seconds);
            document.getElementById("sitetime").innerHTML="已在这里 "+diffYears+" 年 "+diffDays+" 天 "+diffHours+" 小时 "+diffMinutes+" 分钟 "+diffSeconds+" 秒";
        }
        siteTime();
    </script>



    </div>
  </footer>

  
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/next-theme-pjax/0.6.0/pjax.min.js" integrity="sha256-vxLn1tSKWD4dqbMRyv940UYw4sXgMtYcK6reefzZrao=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.umd.js" integrity="sha256-ytMJGN3toR+a84u7g7NuHm91VIR06Q41kMWDr2pq7Zo=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/lozad.js/1.16.0/lozad.min.js" integrity="sha256-mOFREFhqmHeQbXpK2lp4nA3qooVgACfh88fpJftLBbc=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script><script src="/js/pjax.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>




  <script src="/js/third-party/fancybox.js"></script>

  <script src="/js/third-party/pace.js"></script>


  




  

  <script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>


 
        <div id="click-show-text"
            data-mobile = false
            data-text = 富强,民主,文明,和谐,自由,平等,公正,法制,爱国,敬业,诚信,友善
            data-fontsize = 15px
            data-random= false>
        </div>
       

      
        <script async src=https://cdn.jsdelivr.net/npm/hexo-next-mouse-effect@latest/click/showText.js></script>
      

      
    




    <script async src="/js/fancybox_param.js"></script>





<!-- APlayer本体 -->



</body>
</html>
